package org.junzerg.Test;

import com.google.common.base.Strings;

/**
 * Created by pengjunzhe on 2018/5/2.
 */
public class StringTest {
    public static void main(String[] args) {
        String s = "hello world";
        String e = "";
        String n = null;
        System.out.println(Strings.nullToEmpty(s)); // "hello world"
        System.out.println(Strings.nullToEmpty(e)); // ""
        System.out.println(Strings.nullToEmpty(n)); // ""
        System.out.println(Strings.emptyToNull(s)); // "hello world"
        System.out.println(Strings.emptyToNull(e)); // null
        System.out.println(Strings.emptyToNull(n)); // null
        System.out.println(Strings.isNullOrEmpty(s)); // false
        System.out.println(Strings.isNullOrEmpty(e)); // true
        System.out.println(Strings.isNullOrEmpty(n)); // true
        System.out.println(Strings.padStart("xx", 4, 'o')); // "ooxx"
        System.out.println(Strings.padEnd("xx", 4, 'o')); // "xxoo"
        System.out.println(Strings.repeat("xx", 3)); // "xxxxxx"
        System.out.println(Strings.commonPrefix("oooo", "ooxx")); // "oo"
        System.out.println(Strings.commonSuffix("xxxx", "ooxx")); // "xx"
    }
}
